package cn.kgc.service.impl;

import cn.kgc.mapper.AddressMapper;
import cn.kgc.pojo.SmbmsAddress;
import cn.kgc.service.AddressService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("addressService")
public class AddressServiceimpl implements AddressService {

    @Resource
    AddressMapper addressMapper;
    @Override
    public int getAddressConut(String contact) {
        return addressMapper.getAddressConut(contact);
    }

    @Override
    public List<SmbmsAddress> getAddressBypage(Integer currentPageNo, Integer pageSize, String contact) {
        Integer pageNo = (currentPageNo-1)*pageSize;
        return addressMapper.getAddressBypage(pageNo,pageSize,contact);
    }

    @Override
    public boolean addAddress(SmbmsAddress smbmsAddress) {
        int count = addressMapper.addAddress(smbmsAddress);
        if (count>0){
            return true;
        }else {
            return false;
        }

    }

    @Override
    public boolean updateAddress(SmbmsAddress smbmsAddress) {
        int count = addressMapper.updateAddress(smbmsAddress);
        if (count>0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public boolean delAddress(Integer id) {
        int count = addressMapper.delAddress(id);
        if (count>0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public SmbmsAddress getpostCode(String postCode) {
        return addressMapper.getpostCode(postCode);
    }

    @Override
    public SmbmsAddress getAddressId(Integer id) {
        return addressMapper.getAddressId(id);
    }
}
